<table class='list'>
	<tr>
		<th>Year-Month</th>
		<th>Total</th>
		<th>Weekly Average</th>
		<th>Distinct Contributors</th>
	</tr>

<% if ! @grouped.empty? %>	

<% @grouped.sort.each do |g,b| %>
	<tr>
		<td><%= g rescue nil %></td>
		<td><%= number_to_currency b.collect {|c| c.amount.to_f}.sum rescue nil %></td>
		<% @w = b.group_by {|c| c.date.strftime('%Y-%W')} %>
		<% t = [] %>
		<% @w.each do |w,g| %>
		 <% t << g.collect {|c| c.amount}.sum %>
		<% end %>
		<td><%= number_to_currency Contribution.average(t) rescue nil %></td>
		<td><%= b.collect {|c| c.contribution.person_id}.uniq.length rescue nil %></td>
	</tr>
<% end %>
</table>
<br>
<table class='list'>
	<tr>
		<th>Summary</th>
		<th></th>
	</tr>
	<tr>
		<td>Total Reported: </td>
		<td>
			<%= number_to_currency @c.collect {|c| c.amount.to_f}.sum rescue nil %>
		</td>
	</tr>
</table>

<% else %>

</table>

<div id="message-black">
	No results
</div>

<% end %>
